package com.mayi.zds.web;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import cn.dsna.util.images.ValidateCode;



@Controller
@RequestMapping("/pictureCode")
public class PictureCodeController {
	@RequestMapping("/loginPic")
	public void getLoginPictureCode(HttpServletRequest req, HttpServletResponse resp){
		//创建验证码对象
		ValidateCode code = new ValidateCode(120, 40, 4, 28);
		//获取真实验证码
		String codeVal = code.getCode();
		System.out.println(codeVal);
		//将验证码值存到session中
		req.getSession().setAttribute("loginPic", codeVal);
		//code.createCode();	
		try {
			code.write(resp.getOutputStream());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
